#!/bin/bash
tar xf shadow-4.8.1.tar.xz 
cd shadow-4.8.1
sed -i 's/groups$(EXEEXT) //' src/Makefile.in
find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \;
find man -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
find man -name Makefile.in -exec sed -i 's/passwd\.5 / /' {} \;
sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' -e's@$1/var/spool/mail@$1/var/mail@' etc/login.defs
sed -i 's/1000/999/' $1/etc/useradd
CFLAGS="$CFLAGS --sysroot=$1" ./configure --sysconfdir=$1/etc --with-group-name-max-length=32 --prefix=$1 --host=$4
make -j$2
make install
cd ..
rm -rf shadow-4.8.1
